<?php
class FriendUsersController extends AppController{
	var $name = 'FriendUsers';
	var $uses = array('FriendUser');
	var $helpers = array('Html','Session');
	var $components = array('Session');
    
    public function addfriend($id=NULL,$friend_id=NULL){
        $fr=array('user_id'=>$id,'friend_id'=>$friend_id,'status'=>0);
        if($this->FriendUser->save($fr))
        $this->redirect(array('controller'=>'UserImageBoards','action'=>'listImages'));
         }
         
  public function friend($id=NULL,$friend_id=NULL){
  if($this->FriendUser->updateAll(array('FriendUser.status_flag'=>"1"),
                                  array('FriendUser.user_id'=>$id,'FriendUser.friend_id'=>$friend_id)))
     $this->redirect(array('controller'=>'UserImageBoards','action'=>'listImages'));
  }
  
  public function destroyfriend($id=null,$friend_id=null){
    $df=$this->FriendUser->find('first',array('conditions'=>
                                              array('OR'=>array(
                                                    'AND'=>array('user_id'=>$id,'friend_id'=>$friend_id),
                                                    'AND'=>array('user_id'=>$friend_id,'friend_id'=>$id)))));
    pr($df);    
    $this->FriendUser->delete($df['FriendUser']['id']);
    $this->redirect(array('controller'=>'Users','action'=>'listfriend'));
      
  }
}
?>